﻿using System;
using System.Collections.Generic;

namespace PenguinPublishNS.Models
{

    public enum ActionType
    {
        Delete,
        Add,
        Update,
        Rename
    }

    public class WebFile // :INotifyPropertyChanged
    {
        public string filepath { get; set; }
        public string filehash { get; set; }
        public bool uploaded { get; set; }
        public DateTime dateUpload { get; set; }
        public DateTime dateModified { get; set; }
        public ActionType Action { get; set; } 
    }

    // Custom comparer for the webfile class 
    public class WebFileComparer : IEqualityComparer<WebFile>
    {
        // Website files/dirs are equal if their filepath and filehash are equal. 
        public bool Equals(WebFile x, WebFile y)
        {

            //Check whether the compared objects reference the same data. 
            if (Object.ReferenceEquals(x, y)) return true;

            //Check whether any of the compared objects is null. 
            if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
                return false;

            //Check whether the webfiles properties are equal. 
            return x.filepath == y.filepath && x.filehash == y.filehash;
        }


        public int GetHashCode(WebFile obj) //must be implemented for IEqualityComparer
        {
            return obj.filepath.GetHashCode();
        }
    }
    
}
